#ifndef _GD25Q_HAL_H_
#define _GD25Q_HAL_H_

#include "stdint.h"
#include "sys.h"
#include "pincfg.h"

#ifdef _GD25Q_HAL_MODEL_
#define GD_EXT
#else
#define GD_EXT extern
#endif

#define Q25_SS PBout(6)

//WP# going low to protected the BP0~BP4 bits and SRP0~1 bits.
#define GD25WpEn()
#define GD25WpDis()
//To re-start communication with chip, the HOLD# must be at high and then CS# must be at low
#define gd25_cs(x) (x ? (Q25_SS = 1) : (Q25_SS = 0))
#define GD25Hold(x)

void gd25_spi_init(void);
uint8_t gd25_spi_rw(uint8_t dataW);
uint8_t gd25_spi_write(uint8_t *dataw, uint32_t Len);
uint8_t gd25_spi_read(uint8_t *datar, uint32_t Len);

void gdSpiDma(uint8_t NewState);
void gd25_spi_dma_read(uint8_t *Data, uint32_t Len);
void gd25_spi_dma_write(uint8_t *Data, uint32_t Len);

#undef GD_EXT

#endif /* _GD25Q_HAL_H_ */
